local skel = fk.CreateSkill {
  name = "lb__xingpao",
}

Fk:loadTranslationTable {
  ["lb__xingpao"] = "星炮",
  [":lb__xingpao"] = "准备阶段，你可以弃置任意张牌（至多为3）后执行等量项：<br>" ..
      "1.摸两张牌；<br>" ..
      "2.本回合使用牌无视距离；<br>" ..
      "3.本回合使用牌不可被响应。<br>" ..
      "然后视为使用一张目标数至多为未执行项数的火【杀】。",

  ["#lb__xingpao"] = "星炮：你可以弃置至多三张牌后执行等量项",
  ["#lb__xingpao-ask"] = "星炮：视为使用一张目标数至多为 %arg 的火【杀】",
  ["lb__xingpao_1"] = "摸两张牌",
  ["lb__xingpao_2"] = "本回合使用牌无视距离",
  ["lb__xingpao_3"] = "本回合使用牌不可被响应",
  ["@lb__xingpao_ju-turn"] = "星炮",
  ["@lb__xingpao_xy-turn"] = "星炮",
  ["lb__xingpao_juli"] = "无视距离",
  ["lb__xingpao_xiangyin"] = "无法响应",


  ["$lb__xingpao1"] = "战斗是一场精密的设计。",
  ["$lb__xingpao2"] = "下一次可就没那么简单了。",
}

skel:addEffect(fk.EventPhaseStart, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and player.phase == Player.Start and not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local success, dat = room:askToUseActiveSkill(player, {
      skill_name = "#lb__xingpao_active",
      prompt = "#lb__xingpao",
      cancelable = true,
    })
    if success and dat then
      event:setCostData(self, { cards = dat.cards, choices = dat.interaction })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cost_data = event:getCostData(self)
    local cards = cost_data.cards
    room:throwCard(cards, skel.name, player, player)
    local choices = cost_data.choices
    if table.contains(choices, "lb__xingpao_1") then
      room:drawCards(player, 2, skel.name)
    end
    if table.contains(choices, "lb__xingpao_2") then
      room:setPlayerMark(player, "@lb__xingpao_ju-turn", "lb__xingpao_juli")
      room:setPlayerMark(player, MarkEnum.BypassDistancesLimit .. "-turn", 1)
    end
    if table.contains(choices, "lb__xingpao_3") then
      room:setPlayerMark(player, "@lb__xingpao_xy-turn", "lb__xingpao_xiangyin")
    end
    local n = 3 - #cards
    if n == 0 then return end
    room:setPlayerMark(player, "lb__xingpao_mb-phase", n - 1)
    room:askToUseVirtualCard(player, {
      name = "fire__slash",
      skill_name = skel.name,
      cancelable = false,
      prompt = "#lb__xingpao-ask:::" .. n,
    })
  end,
})

skel:addEffect(fk.PreCardUse, {
  mute = true,
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and
        player:getMark("@lb__xingpao_xy-turn") ~= 0
  end,
  on_use = function(self, event, target, player, data)
    data.disresponsiveList = player.room.players
  end,
})

skel:addEffect("targetmod", {
  extra_target_func = function(self, player, skill, card)
    if player:hasSkill(skel.name) and card.skillName == skel.name then
      return player:getMark("lb__xingpao_mb-phase")
    end
  end,
})

return skel
